﻿#NoEnv
#SingleInstance, Force
CoordMode, Mouse, Screen
SetTitleMatchMode, 1
SetWorkingDir %A_ScriptDir%

OnMessage(0x200, "WM_MOUSEMOVE")

;{___  Tray Icon/Menu  ______________________________________________________________________________________

Menu, Tray, Icon, res\c0bra.ico
Menu, Tray, Add, Reload, ReloadMe
Menu, Tray, Add, Settings, Gui
Menu, Tray, Add, Exit, closer
Menu, Tray, Default, Settings
Menu, Tray, tip, c0bra!
;}


global COBRA	:= A_ScriptDir

USER_SETTINGS 	:= A_ScriptDir "\user\user_settings.ini"
GUI_SETTINGS 	:= A_ScriptDir "\config\Gui.ini"
HKEY_SETTINGS 	:= A_ScriptDir "\user\Hotkeys.ini"
USER_FUNCTIONS 	:= A_ScriptDir "\user\user_functions.ahk"
C0BRA_INFO 		:= A_ScriptDir "\c0bra_info.ini"

USER_INI 		:= new ini(USER_SETTINGS)

FileRead, VERSION, version

;}



;{___  Register Hotkeys  _________________________________________________________________________


	;{```````  User Hotkeys  ```````}
	SUPER_KEYS := USER_INI.Keys("UserHotkeys")
	loop, parse, SUPER_KEYS, `n, `r
		if ((thisHK := Trim(A_LoopField)) != "")
			Hotkey, %thisHK%, SUPER_SHORTS	;}


	;{```````  Main Hotkey  ```````}
	mainHotkey := Trim(USER_INI.MainHotkey.Hotkey)	
	winList := Trim(USER_INI.MainHotkey.DisableIfActiveList)
	Loop, parse, winList, csv
		if ((thisWin := Trim(A_LoopField)) != "")
			GroupAdd, MainNoRunGroup, %thisWin%
	Hotkey, IfWinNotActive, ahk_group MainNoRunGroup
	Hotkey, %mainHotkey%, MAIN_TRIGGER 	;}


	;{```````  The Closer  ```````}
	closerHK := Trim(USER_INI.TheCloser.Hotkey)
	winList := Trim(USER_INI.TheCloser.DisableIfActiveList)
	Loop, parse, winList, csv
	if ((thisWin := Trim(A_LoopField)) != "")
		GroupAdd, CloserNoRunGroup, %thisWin%
	Hotkey, IfWinNotActive, ahk_group CloserNoRunGroup
	Hotkey, %closerHK%, THE_CLOSER	;}

	
	;{```````  Search Submit Hotkeys  ```````}
	Hotkey, IfWinActive, c0bra Main GUI
	Hotkey, *Enter, ButtonPress
	Hotkey, IfWinActive, c0bra Main GUI
	Hotkey, *NumPadEnter, ButtonPress
	hotkey, ifwinactive, ;}

return  ;}



#Include <GUI>
#Include <UserFunctions>
#Include <Methods>
#Include <CControlColors>
#Include <CIni>
#Include <CConfig>
